import { Component, Input, OnInit } from '@angular/core';
import { AppGlobalService } from 'src/app/shared/service/app-global.service';
import { HttpService } from 'src/app/shared/service/http.service';
import { PageModalService } from 'src/app/shared/service/page-modal-service';
import { ModalController, AlertController, IonContent } from '@ionic/angular';
import { EventService } from 'src/app/shared/service/event.service';
declare let $: any;
@Component({
  selector: 'app-tabs-ng-zorro-mobile',
  templateUrl: './tabs-ng-zorro-mobile.component.html',
  styleUrls: ['./tabs-ng-zorro-mobile.component.scss'],
})
//tslint:disable
export class TabsNgZorroMobileComponent implements OnInit {
  flag = true;
  index = 0;
  @Input() tagData;
  tabBarUnderlineStyle: any;
  tabBarTextStyle: any;
  isSpinning = false;
  diffTime = 180; // 默认3分钟 180
  result: any = { showName: "", filter: {}, order: {} };
  currentDataArray = [];
  currentFixedTagArray = [];
  tabBarBackGroundColor = '#FFFFFF'; // 默认值 #FFFFFF
  tabsBackGroundColor = '#FFFFFF'; // 默认值 #FFFFFF
  tabTitleSize = "null"; // 支持配置
  codeParamsForCssType4 = "";
  tabPageShowCount = 4;// 默认显示4个
  mainTabBoxCssStyle = ''; // 当前组件最外层div 样式
  secondMainTabCssStyle = ''; // 当前组件最外层div 子DIV
  secondMainTabPositionUnset = false; // 当前组件最外层div 子DIV
  hidenTabCssStyle = '';  // 当前组件最外层div 子DIV 的 子DIV
  tabLeftBoxCssStyle = ''; // 当前组件最外层div 子DIV 的 子DIV 里面左边的一层div
  ztabId = 'tabsNgZorroMobile';
  isShowHideTab = false;
  isHideSlideBox = false; // 默认显示
  isShowCssType3Slide = false;
  isShowCustomCssType3Slide = false;
  isWidthAuto = false;
  isShowhidenSlideBox = false;
  headTitle: any;// 新增标题用于 1.7.0赚钱宝
  headTitleCssStyle: any;// 标题样式
  itemTabId = 'itemTabId';
  isShowLoading = false;// 蜂喔商户1.6.29 是否显示正在加载

  headRightTipIcon: any;
  headRightTipIconCssStyle: any;
  headRightTipLabel: any;
  headRightTipLabelCssStyle: any;

  // 2023.11.21 配置view下拉刷新请求指定的part说明
  // 例子：shop_center_list_view 属性1 和属性2 必须同时配置才能生效
  // 属性 1.needRefreshCurrentTab 用于创建触发事件函数开关 值：true,false
  // 属性 2.refreshEventName 用于创建接收刷新命令函数 值：自定义唯一标识字符串 配置方法:createOrderNo() 可以每次随机生成唯一字符。
  // 属性 3.enableRefresh 当有5个选项卡只在其中一个tab中配置了enableRefresh=true则这个配置了的会重新请求part接口
  // 配置方法如下：
  // <tab label="全部" indexTab="0">
  // <partLink type="view" target="recommend_shop_list_view">
  //   <!--2023.11.21 【组合配置 下面两个配置需要同时配置】begin-->
  //   <!-- 决定是否需要在页面下拉时刷新-->
  //   <param name="needRefreshCurrentTab" value="true"></param>
  //   <!-- 项目唯一刷新事件标识ID 保证全项目唯一即可-->
  //   <param name="refreshEventName" value=":createOrderNo()"></param>
  //   <!--2023.11.21 【组合配置 下面两个配置需要同时配置】end-->
  //   <param name="enableRefresh" value="true"></param>
  enableRefresh = false;// 用于缓存当前选项卡页面之后，view中下拉整个页面刷新指定的选项卡  2023.11.21
  needRefreshTabPageId;// 2024.06.19 2.3.3 版本新增 用户更新tab选项卡属性


  constructor(
    private appGlobalService: AppGlobalService,
    private pageModalService: PageModalService,
    private httpService: HttpService,
    private modalController: ModalController,
    private eventService: EventService
  ) {
    const that = this;
    // 2023.11.21 创建刷新控制器触发中心  
    setTimeout(() => {
      if (that.tagData.data[0]
        && that.tagData.data[0].partLink.params.needRefreshCurrentTab !== undefined
        && that.tagData.data[0].partLink.params.needRefreshCurrentTab === 'true') {
        console.log('currentZtabId= 控制触发模块初始化...' + that.tagData.data[0].partLink.params.refreshEventName, that.ztabId);
        that.eventService.eventEmit.on("scrollToRefreshByNeedRefreshCurrentTab", (obj) => {

          // console.log('currentIndexTab=', that.tagData.currentData.currentTab);
          // const tabId = 'tab' + this.ztabId + obj.currentTab;
          // if(document.getElementById(tabId)){
          //   document.getElementById(tabId).click();
          // }
          // 按照 顺序 获取当前tab 里面的tab 切换标签
          // const ionRouterOutlet = document.getElementsByTagName('ion-router-outlet');
          // if (ionRouterOutlet && ionRouterOutlet[1]) {
          //   try {
          //     const tabTtmlCollection = ionRouterOutlet[1];
          //     const len = tabTtmlCollection.children.length;
          //     for (let i = 0; i < len; i++) {
          //       const tempTabObj = tabTtmlCollection.children[i];
          //       // 当前在前台的tab
          //       if (!tempTabObj.classList.contains('ion-page-hidden')) {
          //         if (that.tagData.data[0].partLink
          //           && that.tagData.data[0].partLink.params
          //           && that.tagData.data[0].partLink.params.refreshEventName) {
          //           // 获取当前控件所在的事件名字有就触发，没有就不触发
          //           // console.log('获取当前控件所在的事件名字triggerRefreshEventName=', that.tagData.data[0].partLink.params.refreshEventName);
          //           localStorage.setItem(that.tagData.data[0].partLink.params.refreshEventName, '1');
          //           that.eventService.eventEmit.emit(that.tagData.data[0].partLink.params.refreshEventName, '1');
          //         }
          //         break;
          //       }
          //     }
          //   } catch (e) {
          //   }
          // }
          localStorage.setItem(that.tagData.data[0].partLink.params.refreshEventName, '1');
          that.eventService.eventEmit.emit(that.tagData.data[0].partLink.params.refreshEventName, '1');
        });
      }
    }, 900);
  }
  ngOnInit() {
    const that = this;
    if (this.tagData && this.tagData.eventName && this.tagData.eventName === 'doubleKill') {
      if (this.eventService.eventEmit.listenerCount(this.tagData.eventName) > 0) {
        this.eventService.eventEmit.removeListener(this.tagData.eventName);
      }
      this.eventService.eventEmit.on(this.tagData.eventName, res => {
        that.onChange(res, true)
      })
    }


    try {

      // 进入页面一秒钟后在注册
      setTimeout(() => {

        if (that.tagData.data[0] && that.tagData.data[0].partLink.params.refreshTabBtn) {
          // console.log('refreshTabBtn', '切换店铺模块初始化...');
          that.eventService.eventEmit.on("refreshTabBtn", (obj) => {
            if (obj && obj.data[0] && obj.data[0].partLink.params.refreshTabBtn === that.tagData.data[0].partLink.params.refreshTabBtn) {
              if (that.currentDataArray[obj.currentTab]) {
                // that.currentDataArray[obj.currentTab] = obj.currentData.tags;
                // 2023.11.22 fixed bug 从供应商店铺切换到维修店铺的时候，更新完当前选项卡，需要初始化当前选项卡之外的其他选项卡，相当于清理缓存。
                // 更新整个tagData 用户切换时part接口调用参数请求
                that.tagData = obj;
                for (let index = 0; index < that.currentDataArray.length; index++) {
                  if (index === (obj.currentTab - 0)) {
                    that.currentDataArray[index] = obj.currentData.tags;
                  } else {
                    that.currentDataArray[index] = undefined;
                  }
                }
              }
            }
          });
        }

        // 2023.11.21 自定义刷新接收处理函数
        if (that.tagData.data[0]
          && that.tagData.data[0].partLink.params.refreshEventName !== undefined
        ) {
          console.log('init refreshEventName' + that.tagData.data[0].partLink.params.refreshEventName, that.itemTabId);
          that.eventService.removeCustomListListenersByName(that.tagData.data[0].partLink.params.refreshEventName);
          that.eventService.eventEmit.on(that.tagData.data[0].partLink.params.refreshEventName, (obj) => {
            if (localStorage.getItem(that.tagData.data[0].partLink.params.refreshEventName)) {
              localStorage.removeItem(that.tagData.data[0].partLink.params.refreshEventName);
              // if (that.tagData.data[0].partLink.params.refreshEventName === '蜂喔服务唯一标识符') {
              //   const tabId = that.itemTabId + that.index;
              //   if (document.getElementById(tabId)) {
              if (that.tagData.data[that.index].partLink.params.enableRefresh) {
                that.enableRefresh = that.tagData.data[that.index].partLink.params.enableRefresh === 'true' ? true : false;
                if (that.enableRefresh) {
                  that.onChange({ index: that.index });
                  console.log('refreshCurrentTab currentTab=' + that.index + '|' + that.itemTabId, '触发刷新...eventName=' + that.tagData.data[0].partLink.params.refreshEventName);
                }
              }
              //   }
              // }

            }
          });
        }

      }, 900);



      // 这样是进行二次请求真实数据
      if (this.tagData.currentData.isShell === true &&
        this.tagData.data &&
        this.tagData.data.length > 0 &&
        this.tagData.currentTab &&
        this.tagData.data[this.tagData.currentTab - 0].partLink &&
        this.tagData.data[this.tagData.currentTab - 0].partLink.target &&
        this.tagData.data[this.tagData.currentTab - 0].partLink.params
      ) {
        const p = JSON.parse(JSON.stringify(this.tagData.data[this.tagData.currentTab - 0].partLink.params));
        p["isShell"] = true;
        const params: any = {
          viewId: this.tagData.data[this.tagData.currentTab - 0].partLink.target,
          sessionId: localStorage.getItem("sessionId"),
          params: p
        }
        this.httpService.postForShellData('application/part', params, true);
      }
      // 第二次真实数据能要删掉某些tag
      this.eventService.eventEmit.on("updateTabsCurrentDataTags" + localStorage.getItem('currentPath'), (obj) => {
        const tags = JSON.parse(obj);
        let temArray: any = [];
        tags.forEach(element => {
          if (element.remove === "true") {
            if (this.currentDataArray[this.index].length > 0) {
              this.currentDataArray[this.index].forEach(e => {
                if (e.shellDataId == element.shellDataId) {
                  temArray.push(e);
                }

              });

            }

          }
        });
        if (temArray.length > 0) {

          temArray.forEach(element => {
            const index = this.currentDataArray[this.index].indexOf(element);
            if (index > -1) {
              this.currentDataArray[this.index].splice(index, 1);
              this.appGlobalService.deleteShellData(element.shellDataId);
              console.log("ngTab remove tag:" + element.shellDataId);
            }
          });

        }
      });

      setTimeout(() => {
        this.appGlobalService.headerTopTabIndex = 0;
      }, 0);
      this.appGlobalService.headerSiftTag = undefined;
      this.itemTabId = this.itemTabId + new Date().getTime();
      this.appGlobalService.itemTabId = this.itemTabId;
      this.ztabId = this.ztabId + new Date().getTime();

      // 2024.06.13 
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.itemTabId) {
        this.itemTabId = this.tagData.data[0].partLink.params.itemTabId;
      }

      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.showHidenTab) {
        this.isShowHideTab = this.tagData.data[0].partLink.params.showHidenTab;
      }
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.isHideSlideBox) {
        this.isHideSlideBox = this.tagData.data[0].partLink.params.isHideSlideBox;
      }
      // 顶部标题 1.7.0 赚钱宝 学习中心新增
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.headTitle) {
        this.headTitle = this.tagData.data[0].partLink.params.headTitle;
      }




      // 2.0 tab tips
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.headRightTipIcon) {
        this.headRightTipIcon = this.tagData.data[0].partLink.params.headRightTipIcon;
      }
      // 2.0 tab tips
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.headRightTipIconCssStyle) {
        this.headRightTipIconCssStyle = this.tagData.data[0].partLink.params.headRightTipIconCssStyle;
      }
      // 2.0 tab tips
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.headRightTipLabel) {
        this.headRightTipLabel = this.tagData.data[0].partLink.params.headRightTipLabel;
      }
      // 2.0 tab tips
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.headRightTipLabelCssStyle) {
        this.headRightTipLabelCssStyle = this.tagData.data[0].partLink.params.headRightTipLabelCssStyle;
      }

      // 2.3.3 refresh tab info
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.needRefreshTabPageId) {
        this.needRefreshTabPageId = this.tagData.data[0].partLink.params.needRefreshTabPageId;
        if (this.tagData.data[0].partLink.params.needRefreshTabEventName) {
          that.eventService.eventEmit.on(this.tagData.data[0].partLink.params.needRefreshTabEventName, (obj) => {
            this.getPageDataAndRefreshTabData(this.needRefreshTabPageId);
          });
        }
      }

      //检查默认选中的tabIndex
      if (this.tagData.data[0].partLink.params.settingAGSName) {
        const indexTabName = this.tagData.data[0].partLink.params.settingAGSName;
        this.appGlobalService[indexTabName] = null;
        delete this.appGlobalService[indexTabName];
      }

      // 顶部标题样式 1.7.0 赚钱宝 学习中心 新增
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.headTitleCssStyle) {
        this.headTitleCssStyle = this.tagData.data[0].partLink.params.headTitleCssStyle;
      }

      // Tabs背景色
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.tabsBackGroundColor) {
        this.tabsBackGroundColor = this.tagData.data[0].partLink.params.tabsBackGroundColor;
      }
      // TabBar背景色
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.tabBarBackGroundColor) {
        this.tabBarBackGroundColor = this.tagData.data[0].partLink.params.tabBarBackGroundColor;
      }
      // TabTitle固定尺寸 为TabTitle设置尺寸(单位：px)。
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.tabTitleSize) {
        this.tabTitleSize = this.tagData.data[0].partLink.params.tabTitleSize;
      }
      // 是否显示自定义滑块
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.isShowCustomCssType3Slide) {
        this.isShowCustomCssType3Slide = this.tagData.data[0].partLink.params.isShowCustomCssType3Slide;
      }

      // 当前组件最外层div 样式
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.mainTabBoxCssStyle) {
        this.mainTabBoxCssStyle = this.tagData.data[0].partLink.params.mainTabBoxCssStyle;
      }

      // 当前组件最外层div 子DIV
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.secondMainTabCssStyle) {
        this.secondMainTabCssStyle = this.tagData.data[0].partLink.params.secondMainTabCssStyle;
      }

      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.secondMainTabPositionUnset) {
        this.secondMainTabPositionUnset = true;
      }

      // 当前组件最外层div 子DIV 的 子DIV
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.hidenTabCssStyle) {
        this.hidenTabCssStyle = this.tagData.data[0].partLink.params.hidenTabCssStyle;
      }

      // 当前组件最外层div 子DIV 的 子DIV  里面左边的一层div]
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.tabLeftBoxCssStyle) {
        this.tabLeftBoxCssStyle = this.tagData.data[0].partLink.params.tabLeftBoxCssStyle;
      }

      // 添加默认值
      if (this.tagData.data[0] && !this.tagData.data[0].partLink.params.hiddenTabCssType) {
        this.tagData.data.forEach(element => {
          element.partLink.params.hiddenTabCssType = '1';
        });
      }

      // 添加是否显示正在加载
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.showLoadingGif) {
        this.isShowLoading = true;
      }

      //2.2.1 新增
      if (that.tagData.data[0].partLink.params.needCheckAndReplaceIndexTab) {
        that.appGlobalService['needCheckAndReplaceIndexTab'] = that.tagData.data[0].partLink.params.needCheckAndReplaceIndexTab;
      }

      // 蜂喔赚钱宝 1.7.1 layout 属性 是否固定到sift筛选栏顶部 
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.layout !== undefined) {
        for (let index = 0; index < this.tagData.data.length; index++) {
          const element = this.tagData.data[index];
          element.id = this.itemTabId + '' + index;
        }
        setTimeout(() => {
          this.appGlobalService.headerTopTab = this.tagData;
        }, 0);
      }

      // this.tagData.cssType = 2;
      // this.tagData.cssType = 3;
      // this.tagData.cssType = 4;
      this.eventService.removeCustomListListeners();
      this.appGlobalService.scResult = { showName: "", filter: {}, order: {} };
      // todo 线上项目预览新增cssType = 5
      // if (this.tagData.data && this.tagData.data[0].label == '装修建材') {
      //   this.tagData.cssType = 5;
      // }
      if (this.tagData.cssType === 2) {
        this.tabBarUnderlineStyle =
        {
          ['background-image']: 'url(assets/fw/indicator.png)',
          ['background-size']: '100%',
          ['background-position']: 'center bottom',
          ['background-repeat']: 'no-repeat',
          ['margin-left']: '-0.75rem',
          ['border-radius']: '0.5rem 0.5rem 0rem 0rem',
          ['margin-bottom']: '0rem',
          ['z-index']: '-1',
          width: (100 / this.tagData.data.length + 5) + '%',
          height: '100%',
          border: 'unset'
        };
        this.tabBarTextStyle = { ['z-index']: 2, ['font-size']: '1.06rem', color: '#45474D', ['font-weight']: 'bold' };
      } else if (this.tagData.cssType === 4) {
        this.tabBarUnderlineStyle = { border: '1px solid #ffffff', bottom: '4px', background: '#ffffff', width: '2rem' };
        this.tabBarUnderlineStyle['margin-left'] = 'calc((50vw - 9rem) * 0.5)';
        this.tabBarTextStyle = { ['z-index']: 2, ['font-size']: '1.06rem', color: '#45474D' };
      } else if (this.tagData.cssType === 5) {
        this.tabBarUnderlineStyle =
        {
          // ['background-image']: 'url(assets/fw/indicator.png)',
          // ['background-size']: '100%',
          // ['background-position']: 'center bottom',
          // ['background-repeat']: 'no-repeat',
          // ['margin-left']: '-0.75rem',
          ['background']: '#FFC800',
          ['border-radius']: '1.5rem',
          ['margin-bottom']: '0rem',
          ['z-index']: '-1',
          width: (100 / this.tagData.data.length) + '%',
          height: '2rem',
          border: 'unset'
        };
        this.tabBarTextStyle = { ['z-index']: 2, ['font-size']: '0.88rem', height: '2rem', color: '#45474D' };
      } else if (this.tagData.cssType === 3) {
        this.tabBarUnderlineStyle = { border: '1px solid transparent', bottom: '0px', background: 'transparent', width: '0rem' };
        // this.tabBarUnderlineStyle['margin-left'] = 'calc((50vw - 9rem) * 0.5)';
        this.tabBarTextStyle = { ['z-index']: 2, ['font-size']: '1.06rem', color: '#45474D' };
      } else if (this.tagData.cssType === 6) {
        this.tabBarUnderlineStyle = { border: '1px solid transparent', bottom: '0px', background: 'transparent', width: '0rem' };
        // this.tabBarTextStyle = { ['z-index']: 2, ['font-size']: '1.06rem', color: '#45474D' };
      } else {
        this.tabBarUnderlineStyle = { border: '1px solid #ffca3a', bottom: '4px', background: '#0A3CA0', width: '2rem' };
        this.tabBarUnderlineStyle['margin-left'] = 'calc((50vw - 9rem) * 0.5)';
        this.tabBarTextStyle = { ['z-index']: 2, ['font-size']: '1.06rem', color: '#45474D' };
      }
      // 隐藏滑块
      if (this.isHideSlideBox) {
        this.tabBarUnderlineStyle = { border: '1px solid transparent', bottom: '0px', background: 'transparent', width: '0rem' };
      } else {
        // 滑块样式
        if (this.tagData.data[0] && this.tagData.data[0].partLink.params.tabBarUnderlineStyle) {
          this.tabBarUnderlineStyle = JSON.parse(this.tagData.data[0].partLink.params.tabBarUnderlineStyle);
        }
      }

      // 是否自定义text样式
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.tabBarTextStyle) {
        this.tabBarTextStyle = this.getNgStyle(this.tagData.data[0].partLink.params.tabBarTextStyle);
      }

      // 是否自定义text样式
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.isWidthAuto !== undefined) {
        this.isWidthAuto = true;
        this.tabBarTextStyle['width'] = '10px !important';
      }

      // 2.1.0 新增替换搜索页面pageId
      if (this.tagData.data[0].partLink.params.homeSearchPageId) {
        console.log('homeSearchPageId', this.tagData.data[0].partLink.params.homeSearchPageId);
        localStorage.setItem('nav1ReplaceSearchPageIdTag', '1');
        let searchPageType = 'default';
        if (this.tagData.data[0].partLink.params.searchPageType) {
          searchPageType = this.tagData.data[0].partLink.params.searchPageType;
        }
        this.eventService.eventEmit.emit('nav1ReplaceSearchPageId', { target: this.tagData.data[0].partLink.params.homeSearchPageId, searchPageType });

      }
      if (this.tagData.data[0].partLink.params.headDivInnerBoxId) {
        const headDivInnerBoxId = this.tagData.data[0].partLink.params.headDivInnerBoxId;
        if (document.getElementById(headDivInnerBoxId)) {
          document.getElementById(headDivInnerBoxId).style.border = this.tagData.data[0].partLink.params.headDivInnerBoxCssStyle;
        }
        const headDivInnerHintText = this.tagData.data[0].partLink.params.headDivInnerHintText ? this.tagData.data[0].partLink.params.headDivInnerHintText : 'headDivInnerHintText';
        if (document.getElementById(headDivInnerHintText)) {
          document.getElementById(headDivInnerHintText).innerText = this.tagData.data[0].partLink.params.firstRowLeftHintLabel;
        }
      }
      // 蜂喔2.1.0新增
      //2.0修改标题栏的背景图片
      if (this.tagData.data[0].partLink.params.HomeHeaderBgBoxBgCssStyle) {
        if (document.getElementById('home-header-bg-box')) {
          document.getElementById('home-header-bg-box').style.backgroundImage = this.tagData.data[0].partLink.params.HomeHeaderBgBoxBgCssStyle;
        }
      }

      if (this.tagData.data[0].partLink.params.outerBoxId) {
        if (document.getElementById(this.tagData.data[0].partLink.params.outerBoxId)) {
          document.getElementById(this.tagData.data[0].partLink.params.outerBoxId).style.backgroundImage =
            this.tagData.data[0].partLink.params.outerBoxBgImg;
        }
      }



      this.appGlobalService.ngZorroTabCurrentTabIndex = this.index;

      this.currentDataArray = new Array(this.tagData.data.length);
      this.tagData.currentData.tags['listTagRefreshTime'] = new Date().getTime() / 1000;

      let tempFixedTags = [];
      let tempCommonTags = [];
      this.tagData.currentData.tags.forEach(element => {
        if (element.style === 'twoCss') {
          tempFixedTags.push(element);
        } else if (element.style === 'oneCss') {
          tempCommonTags.push(element);
        } else if (element.style === 'three') {
          tempFixedTags.push(element);
        } else if (element.style === 'tag.FilterTagLogic') {
          // 蜂喔赚钱宝1.7.1 新增 用于固定到顶部 <!--前端新增用于维保1.7.1 蜂喔赚钱宝新增需求 注意 这个 name 一定要以_linearLayout_header 结尾 -->
          if (element.name.includes('_linearLayout_header')) {
            setTimeout(() => {
              that.appGlobalService.headerSiftTag = undefined;
              that.appGlobalService.headerSiftTag = element;
            }, 50);
          } else {

            if (element && element.filterItems && element.filterItems.length > 0
              && element.filterItems[0].link !== undefined
              && element.filterItems[0].link.params
              && element.filterItems[0].link.params.useSiftComponent !== undefined
              && element.filterItems[0].link.params.useSiftComponent === 'false'
            ) {
              tempCommonTags.push(element);
            } else {
              tempFixedTags.push(element);
              this.currentFixedTagArray[this.index] = tempFixedTags;
            }


          }
          // console.log('elementName=' + element.name);
        } else {
          // 蜂喔赚钱宝1.7.1 新增tab切换底部有按钮
          if (element && element.linearLayout && element.linearLayout === 'footer'
            && (element.style === 'tag.AppGeneralButtonTagLogic'
              || element.style === 'tag.AppSimpleDetailTagLogic')
          ) {
            setTimeout(() => {
              this.appGlobalService.footerButton = element;
            }, 0);
          } else {
            tempCommonTags.push(element);
          }
        }
      });
      const tempConvertObj = JSON.parse(JSON.stringify(tempCommonTags));
      setTimeout(() => {
        if (that.currentDataArray[this.index] === undefined) {
          that.currentDataArray[this.index] = tempConvertObj;
        }
      }, 0);

      // this.currentDataArray[this.index] = tempCommonTags;

      // tabPageShowCount 
      if (this.tagData.data[0] && this.tagData.data[0].partLink.params.tabPageShowCount) {
        this.tabPageShowCount = this.tagData.data[0].partLink.params.tabPageShowCount;
      } else {
        this.tabPageShowCount = this.tagData.data.length >= 4 ? 4 : 3;
      }
      // width: 30%;
      // left: 50%;
      // border-radius: 0.5rem 0.5rem 0rem 0rem;
      // height: 100%;
      // border: unset;
      // background-image: url(assets/fw/indicator.png);
      // background-size: 100%;
      // background-position: center bottom;
      // margin-left: -10px;
      // background-repeat: no-repeat;
    } catch (e) {
      this.index = 0;
      this.appGlobalService.ngZorroTabCurrentTabIndex = this.index;
    }
    console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '  对 tab进行重新排序  ', '  	   ');

    // 2024.07.03 支持排序
    this.tagData.data.sort((a, b) => {
      return a.indexTab - b.indexTab;
    });

    this.index = parseInt(this.tagData.currentTab);
      // 2024.09.24 新增使用part接口的参数作为局部刷新时请求part接口的参数，例如销售推广中的商机入口-》转让
      if (this.tagData.data[0].partLink.params.usePartParamsForAjaxRefresh) {
        this.appGlobalService.currentPartParams = this.tagData.data[this.index].partLink.params;
      }
    // console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '  	index  ', this.index);
    // 蜂喔商户 顶部tab切换 索引
    if (this.index > 0) {
      setTimeout(() => {
        this.appGlobalService.headerTopTabIndex = this.index;
      }, 50);
    }

    // 重新排序后需要指定选择的选项卡
    for (let j = 0; j < this.tagData.data.length; j++) {
      const element = this.tagData.data[j];
      if (element.indexTab === this.tagData.currentTab) {
        this.tagData.currentTab = j + '';
        break;
      }
    }
  }

  onChange(item, doubleKill?) {
    if (!doubleKill) {
      this.eventService.eventEmit.emit('doubleKill', item);
    }



    setTimeout(() => {
      if (!this.tagData.data[item.index].partLink) {
        return;
      }

      // console.log('this.tagData.currentTab=', this.tagData.currentTab);
      if (item && item.index !== undefined
        && parseInt(item.index) === 0
        && this.currentFixedTagArray[0]
        && this.currentFixedTagArray[0][0]
        && this.currentFixedTagArray[0][0].style === 'tag.FilterTagLogic') {
        this.currentFixedTagArray[0][0] = [];
      }

      if (this.isShowLoading) {
        this.httpService.delayShowLoading();
      }

      this.eventService.removeCustomListListeners();
      //赚钱宝1.7.0 用于切换时 更新全选按钮。
      this.eventService.eventEmit.emit('recommendAllResult', false);
      this.appGlobalService.scResult = { showName: "", filter: {}, order: {} };
      const that = this;
      this.index = item.index;
      this.appGlobalService.ngZorroTabCurrentTabIndex = this.index;
      // const nowTime = new Date().getTime() / 1000; // 三分钟内不刷新
      // if ((this.currentDataArray[this.index] && this.currentDataArray[this.index]['listTagRefreshTime']
      //   && (nowTime - this.currentDataArray[this.index]['listTagRefreshTime'] < this.diffTime))) {
      //   return;
      // }
      if (that.tagData.cssType === 2) {
        that.tabBarUnderlineStyle['margin-left'] = that.index === 0 ? '-0.75rem' : '-0.5rem';
      } else if (that.tagData.cssType === 4) {
        //todo 带筛选的弹窗需额外带参数处理
        if (that.tagData.data[item.index].partLink.params.shop_goods_goods_class_path !== undefined) {
          that.codeParamsForCssType4 = that.tagData.data[item.index].partLink.params.shop_goods_goods_class_path;
        } else {
          that.codeParamsForCssType4 = "";
        }
      }

      if (this.tagData.data[item.index] && this.tagData.data[item.index].partLink) {


        // 2024.09.24 新增使用part接口的参数作为局部刷新时请求part接口的参数，例如销售推广中的商机入口-》转让
        if (this.tagData.data[item.index].partLink.params.usePartParamsForAjaxRefresh) {
          this.appGlobalService.currentPartParams = this.tagData.data[item.index].partLink.params;
        }

        //检查默认选中的tabIndex
        if (this.tagData.data[0].partLink.params.settingAGSName) {
          const indexTabName = this.tagData.data[0].partLink.params.settingAGSName;
          this.appGlobalService[indexTabName] = item.index;
        }

        // 是否需要更新颜色 needChangeBgColor
        if (this.tagData.data[item.index].partLink.params.needChangeBgColor) {
          // 2.0 新增secondMainTabCssStyle背景色
          if (this.tagData.data[item.index].partLink.params.secondMainTabCssStyle) {
            this.secondMainTabCssStyle = this.tagData.data[item.index].partLink.params.secondMainTabCssStyle;
          }
          if (this.tagData.data[item.index].partLink.params.secondMainTabPositionUnset) {
            this.secondMainTabPositionUnset = this.tagData.data[item.index].partLink.params.secondMainTabPositionUnset;
          }
          // 2.0 新增hidenTabCssStyle背景色
          if (this.tagData.data[item.index].partLink.params.hidenTabCssStyle) {
            this.hidenTabCssStyle = this.tagData.data[item.index].partLink.params.hidenTabCssStyle;
          }
          // 2.0 新增tabLeftBoxCssStyle背景色
          if (this.tagData.data[item.index].partLink.params.tabLeftBoxCssStyle) {
            this.tabLeftBoxCssStyle = this.tagData.data[item.index].partLink.params.tabLeftBoxCssStyle;
          }

          //2.0修改标题栏的背景图片
          // topHomeHeaderBgBox = el.getElementsByClassName('home-header-bg-box')[0] as HTMLElement;

          if (this.tagData.data[item.index].partLink.params.HomeHeaderBgBoxBgCssStyle) {
            if (document.getElementById('home-header-bg-box')) {
              document.getElementById('home-header-bg-box').style.backgroundImage = this.tagData.data[item.index].partLink.params.HomeHeaderBgBoxBgCssStyle;
            }
          }

          if (this.tagData.data[item.index].partLink.params.outerBoxId) {
            if (document.getElementById(this.tagData.data[item.index].partLink.params.outerBoxId)) {
              document.getElementById(this.tagData.data[item.index].partLink.params.outerBoxId).style.backgroundImage = this.tagData.data[item.index].partLink.params.outerBoxBgImg;
            }
          }
        }

        if (this.tagData.data[item.index].partLink.params.headerBgColor) {
          // superToolclass
          let header;


          if (document.getElementsByClassName("superToolclass") && document.getElementsByClassName("superToolclass")[0]) {
            header = document.getElementsByClassName("superToolclass")[0] as HTMLElement;
          }
          if (header) {
            header.style.background = this.tagData.data[item.index].partLink.params.headerBgColor;
          }
        }
        if (this.tagData.data[item.index].partLink.params.header2BgColor) {
          let header2;
          if (document.getElementsByClassName("bottomSearchBox") && document.getElementsByClassName("bottomSearchBox")[0]) {
            header2 = document.getElementsByClassName("bottomSearchBox")[0] as HTMLElement;
          }
          if (header2) {
            header2.style.background = this.tagData.data[item.index].partLink.params.header2BgColor;
          }
        }

        // 2.0  是否关闭 加载图标
        if (this.tagData.data[item.index].partLink.params.disableSpinning) {
          this.isSpinning = false;
        } else {
          // 默认启用Spining
          if (this.currentDataArray[this.index] === undefined) {
            this.isSpinning = true;
          } else {
            this.isSpinning = false;
          }
        }

        // 2.1.0 新增替换搜索页面pageId
        if (this.tagData.data[item.index].partLink.params.homeSearchPageId) {
          console.log('homeSearchPageId', this.tagData.data[item.index].partLink.params.homeSearchPageId);
          localStorage.setItem('nav1ReplaceSearchPageIdTag', '1');
          let searchPageType = 'default';
          if (this.tagData.data[item.index].partLink.params.searchPageType) {
            searchPageType = this.tagData.data[item.index].partLink.params.searchPageType;
          }
          this.eventService.eventEmit.emit('nav1ReplaceSearchPageId', { target: this.tagData.data[item.index].partLink.params.homeSearchPageId, searchPageType });

        }
        if (this.tagData.data[item.index].partLink.params.headDivInnerBoxId) {
          const headDivInnerBoxId = this.tagData.data[item.index].partLink.params.headDivInnerBoxId;
          if (document.getElementById(headDivInnerBoxId)) {
            document.getElementById(headDivInnerBoxId).style.border = this.tagData.data[item.index].partLink.params.headDivInnerBoxCssStyle;
          }
          const headDivInnerHintText = this.tagData.data[item.index].partLink.params.headDivInnerHintText ? this.tagData.data[item.index].partLink.params.headDivInnerHintText : 'headDivInnerHintText';
          if (document.getElementById(headDivInnerHintText)) {
            document.getElementById(headDivInnerHintText).innerText = this.tagData.data[item.index].partLink.params.firstRowLeftHintLabel;
          }
        }

        //2.2.1 新增

        if (that.tagData.data[0].partLink.params.needCheckAndReplaceIndexTab && that.tagData.data[0].partLink.params.subTabIndexTab) {
          if (that.appGlobalService[that.tagData.data[0].partLink.params.needCheckAndReplaceIndexTab]) {
            that.tagData.data[item.index].partLink.params['subTabIndexTab'] = that.appGlobalService[that.tagData.data[0].partLink.params.needCheckAndReplaceIndexTab];
          }
        }

        // 添加 自定义属性
        if (this.tagData.data[item.index].partLink.params.customName && this.tagData.data[item.index].partLink.params.customValue) {
          localStorage.setItem(this.tagData.data[item.index].partLink.params.customName, this.tagData.data[item.index].partLink.params.customValue);
        }

        // 删除removeCustomValue
        if (this.tagData.data[item.index].partLink.params.removeCustomValue) {
          localStorage.removeItem(this.tagData.data[item.index].partLink.params.removeCustomValue);
        }


        // 2023.11.27 新增自定义ion-content bgCssStyle 用于控制页面背景
        if (this.tagData.data[item.index].partLink.params.currentTabIonContentBgCssStyle) {
          this.setCurrentScrollElementBgColor(this.tagData.data[item.index].partLink.params.currentTabIonContentBgCssStyle);
        }

        // 2023.11.24 enableRefresh 支持可以配置
        if (this.tagData.data[item.index].partLink.params.enableRefresh
          && this.tagData.data[item.index].partLink.params.enableRefresh === 'true'
        ) {
          this.enableRefresh = true;
        } else {
          this.enableRefresh = false;
        }

        // 2024.07.06
        if (this.tagData.data[item.index].partLink.params.longitude
          && this.tagData.data[item.index].partLink.params.latitude
          && this.tagData.data[item.index].partLink.params.disableUseStorePosition === undefined
        ) {
          if (localStorage.getItem("position")) {
            let position = JSON.parse(localStorage.getItem("position"));
            if (position.center && position.center.lat && position.center.lng) {
              this.tagData.data[item.index].partLink.params.latitude = position.center.lat;
              this.tagData.data[item.index].partLink.params.longitude = position.center.lng;
            }
          }
        }

        // 2.2.16
        if (this.tagData.data[item.index].partLink.params.useSelectedPosition !== undefined
          && this.tagData.data[item.index].partLink.params.useSelectedPosition === 'true') {
          if (this.appGlobalService.getAddressLng) {
            this.tagData.data[item.index].partLink.params.longitude = this.appGlobalService.getAddressLng;
          }
          if (this.appGlobalService.getAddressLat) {
            this.tagData.data[item.index].partLink.params.latitude = this.appGlobalService.getAddressLat;
          }
        }

        try {
          //? 蜂喔商户1.6.21 新增筛选
          that.appGlobalService.openBackdrop = false;
          that.appGlobalService.headerSiftTag = null;
          that.tagData.data[item.index].partLink.params["forNgTabs"] = "true";

          if (this.currentDataArray[this.index] === undefined || this.enableRefresh) {
            this.httpService.post('application/part',
              {
                viewId: that.tagData.data[item.index].partLink.target,
                sessionId: localStorage.getItem("sessionId"),
                params: that.tagData.data[item.index].partLink.params,
                tagOrder: 0
              }, (res: any) => {
                if (res) {
                  setTimeout(() => {
                    that.appGlobalService.headerSiftTag = null;

                  }, 50);
                  setTimeout(() => {
                    that.appGlobalService.footerButton = undefined;
                  }, 0);
                  const tmpData = JSON.parse(res.script);
                  this.tagData.currentData = tmpData;
                  tmpData.tags['listTagRefreshTime'] = new Date().getTime() / 1000;
                  // this.currentDataArray[this.index] = tmpData.tags;
                  const tempFixedTags = [];
                  const tempCommonTags = [];
                  tmpData.tags.forEach(element => {
                    if (element) {

                      if (element.style === 'twoCss') {
                        tempFixedTags.push(element);
                      } else if (element.style === 'oneCss') {
                        tempCommonTags.push(element);
                      } else if (element.style === 'three') {
                        tempFixedTags.push(element);
                      } else if (element.style === 'tag.FilterTagLogic') {
                        // 蜂喔赚钱宝1.7.1 新增 用于固定到顶部 <!--前端新增用于维保1.7.1 蜂喔赚钱宝新增需求 注意 这个 name 一定要以_linearLayout_header 结尾 -->
                        if (element.name.includes('_linearLayout_header')) {
                          setTimeout(() => {
                            // that.appGlobalService.headerSiftTag = null;
                            that.appGlobalService.headerSiftTag = element;
                          }, 50);

                        } else {
                          if (element && element.filterItems && element.filterItems.length > 0
                            && element.filterItems[0].link !== undefined
                            && element.filterItems[0].link.params
                            && element.filterItems[0].link.params.useSiftComponent !== undefined) {
                            tempCommonTags.push(element);
                          } else {
                            tempFixedTags.push(element);
                            this.currentFixedTagArray[this.index] = tempFixedTags;
                          }
                        }
                        // console.log('elementName=' + element.name);
                      } else {
                        // 蜂喔赚钱宝1.7.1 新增tab切换底部有按钮
                        if (element && element.linearLayout && element.linearLayout === 'footer' && (element.style === 'tag.AppGeneralButtonTagLogic' || element.style === 'tag.AppSimpleDetailTagLogic')) {
                          setTimeout(() => {
                            that.appGlobalService.footerButton = undefined;
                            that.appGlobalService.footerButton = element;
                          }, 0);
                        } else {
                          tempCommonTags.push(element);
                        }
                      }
                    }

                  });

                  // 2023.12.13 防止商品分类被覆盖
                  if (this.currentDataArray[this.index] === undefined || this.enableRefresh) {
                    this.currentDataArray[this.index] = tempCommonTags;
                  }
                  that.isSpinning = false;
                }
              });

          }

        } catch (error) {
          console.log('msg----->' + JSON.stringify(error));
        }
      }

    }, 50);

  }
  onTabClick(item) {
  }
  changeIndex() {
    this.index = 0;
    this.appGlobalService.ngZorroTabCurrentTabIndex = this.index;
  }
  goPage(item, isMoreBtn?) {
    if (isMoreBtn) {
      this.appGlobalService.needAutoChoosenTab = true;
    }
    if (item.submit && item.link) {
      const params = {
        content: item.submit.params,
        id: item.submit.id,
        sessionId: localStorage.getItem("sessionId")
      };
      this.httpService.post("application/submit", params, res => {
        if (res.success) {
          this.appGlobalService.openPage(item.link);
        } else {
          if (res.message) {
            this.appGlobalService.showToast(res.message, 2000, "middle");
          }
        }
      });
    } else if (item.link) {
      this.appGlobalService.openPage(item.link);
    }
  }

  openModal(item) {
    const that = this;
    // item.type = "pageModal"
    // 筛选时新增类别参数
    if (item.params !== undefined && item.params.code !== undefined) {
      item.params.code = that.codeParamsForCssType4;
    }
    this.pageModalService.openPage(item, '', (result) => {
      // 发送tagListName 给列表
      if (result && result.filter) {
        const filterTagName = that.currentDataArray[that.index][0].name + 'AskForList';
        that.eventService.eventEmit.emit(filterTagName, result);
      }
      // console.log('console1->', result);
      // console.log('console2->', that.currentDataArray[that.index]);
    });
  }
  // 2024.06.19 for refreshTabData 
  getPageDataAndRefreshTabData(pageId) {

    const that = this;

    if (pageId) {
      console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '  	##############  ', '  	   ');
      const params = {
        sessionId: localStorage.getItem("sessionId"),
        // tslint:disable-next-line:radix
        pageId: parseInt(pageId),
        params: {}
      };

      this.httpService.post('application/page', params, res => {
        this.pageModalService.getTagDataByStyleNameWithPageRes(
          that.tagData.style,
          that.tagData.name,
          res,
          data => {
            // console.log('currentPageData =', data);
            if (data) {
              // that.tagData.data = null;
              that.tagData.data = data.data;
              that.appGlobalService.refreshViewTree(50);
            }
          });
      });
    }
  }

  // onScroll(e: any) {
  //   this.content.ionScroll.subscribe(($event: any) => {
  //     console.log('msg----->' + $event.detail.scrollTop);
  //     localStorage.setItem('dynamicScrollTop', $event.detail.scrollTop);
  //   });
  // }


  ngAfterViewInit(): void {
    //Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
    //Add 'implements AfterViewInit' to the class.

    if (document.getElementById(this.ztabId + this.index)) {
      const content = document.getElementById(this.ztabId + this.index) as HTMLElement;
      const hideTabId = 'hide' + this.ztabId;
      content.addEventListener('scroll', (e) => {
        let scrollToTop = content.scrollTop;
        if (scrollToTop > 0) {
          this.isShowCssType3Slide = true;
          $('#' + hideTabId).addClass("hideTab1");
          $('#' + hideTabId).removeClass("hideTabred");
          this.isShowhidenSlideBox = true;
        } else if (scrollToTop === 0) {
          this.isShowhidenSlideBox = false;
          $('#' + hideTabId).addClass("hideTabred");
          $('#' + hideTabId).removeClass("hideTab1");
          this.isShowCssType3Slide = false;
        }
      });
    }


    //2023年9月16日新增自动滑动到传递的选项卡
    const hideTabId = 'hide' + this.ztabId;
    if (document.getElementById(hideTabId) && this.tagData.data[0].partLink.params.automaticSliding) {
      console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + ' sliding 	   ', this.index);
      document.getElementById(hideTabId).children[this.index].scrollIntoView();
    }

  }


  tabClick(i) {
    // console.log('tabClick', new Date().getTime().toLocaleString());
    if (this.index === i) {
      if (this.tagData.data[i].partLink
        && this.tagData.data[i].partLink.params
        && this.tagData.data[i].partLink.params.enableClickAlreadyCheckedBtn === 'true') {
        this.onChange({ index: this.index });
        return;
      } else {
        return;
      }
    }
    setTimeout(() => {
      const tabId = 'tab' + this.ztabId + i;
      if (this.tagData.data && this.tagData.data[this.tagData.data.length - 1].partLink === undefined && this.tagData.data[this.tagData.data.length - 1].link === undefined) {
        const lastTabId = 'tab' + this.ztabId + (this.tagData.data.length - 1);
        if (document.getElementById(lastTabId)) {
          document.getElementById(lastTabId).click();
        }
        // setTimeout(() => {
        if (document.getElementById(tabId)) {
          document.getElementById(tabId).click();
        }
        // }, 50);
      } else {
        // 2.2.0新增属性用于关闭点击事件
        if (this.tagData.data[i].partLink && this.tagData.data[i].partLink.params && this.tagData.data[i].partLink.params.disableClick) {
          return;
        }

        if (this.tagData.data[i].partLink && this.tagData.data[i].partLink.params && this.tagData.data[i].partLink.params.link_target) {
          let link =
          {
            params: this.tagData.data[i].partLink.params,
            target: this.tagData.data[i].partLink.params.link_target,
            type: this.tagData.data[i].partLink.params.link_type
          };
          this.pageModalService.openPage(link);
          return;
        }


        if (document.getElementById(tabId)) {
          document.getElementById(tabId).click();
        }


      }


      if (document.getElementById(this.ztabId + this.index)) {
        const content = document.getElementById(this.ztabId + this.index) as HTMLElement;
        const hideTabId = 'hide' + this.ztabId;
        content.addEventListener('scroll', (e) => {
          let scrollToTop = content.scrollTop;
          if (scrollToTop > 0) {
            this.isShowCssType3Slide = true;
            $('#' + hideTabId).addClass("hideTab1");
            $('#' + hideTabId).removeClass("hideTabred");
            this.isShowhidenSlideBox = true;
          } else if (scrollToTop === 0) {
            this.isShowhidenSlideBox = false;
            $('#' + hideTabId).addClass("hideTabred");
            $('#' + hideTabId).removeClass("hideTab1");
            this.isShowCssType3Slide = false;
          }
        });
      }
    }, 0);

  }
  getNgStyle(value) {
    if (value) {
      const cssStyles = value.split(";");
      const newStyle = {};
      for (let i = 0; i < cssStyles.length; i++) {
        const cssStrs = cssStyles[i].split(":");
        newStyle[cssStrs[0]] = cssStrs[1];
      }
      return newStyle;
    }
  }

  ngOnDestroy(): void {
    setTimeout(() => {

      // 清空底部按钮 
      this.appGlobalService.footerButton = undefined;
      // 删除顶部筛选
      this.appGlobalService.headerSiftTag = undefined;
      this.appGlobalService.headerTopTab = undefined;
    }, 0);
    if (this.tagData.data
      && this.tagData.data[0].partLink
      && this.tagData.data[0].partLink.params) {
      for (let index = 0; index < this.tagData.data.length; index++) {
        const element = this.tagData.data[index];
        if (element
          && element.partLink
          && element.partLink.params
          && element.partLink.params.usePartParamsForAjaxRefresh
          && element.partLink.params.usePartParamsForAjaxRefresh === 'true') {
          this.appGlobalService.currentPartParams = null;
          this.appGlobalService.consoleLog('init currentPartParams ... ', '  	   ');
          break;
        }
      }
    }
  }


  // 2023.11.27 获取当前dom
  async setCurrentScrollElementBgColor(color) {
    let currentDom;
    // 按照 顺序 获取当前tab 里面的tab 切换标签
    const ionRouterOutlet = document.getElementsByTagName('ion-router-outlet');
    if (ionRouterOutlet && ionRouterOutlet[1]) {
      try {
        const tabTtmlCollection = ionRouterOutlet[1];
        const len = tabTtmlCollection.children.length;
        for (let i = 0; i < len; i++) {
          const tempTabObj = tabTtmlCollection.children[i];
          // 当前在前台的tab
          if (!tempTabObj.classList.contains('ion-page-hidden')) {
            let ionScroll = await tempTabObj.getElementsByTagName('ion-content')[0].getScrollElement();
            ionScroll.style.background = color;
            break;
          }
        }
      } catch (e) {
      }
    }
  }
}

